//
//  ViewController2.m
//  VideoDemo
//
//  Created by Bernie on 2018/8/2.
//  Copyright © 2018年 Bernie. All rights reserved.
//

#import "ViewController2.h"
#import <GPUImage.h>
#import "GPUimageTransparent.h"

@interface ViewController2 ()

@end

@implementation ViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    NSURL *videoUrl = [[NSBundle mainBundle] URLForResource:@"bg" withExtension:@"mp4"];
    GPUImageMovie* movie = [[GPUImageMovie alloc] initWithURL:videoUrl];
    movie.playAtActualSpeed = YES;
    movie.shouldRepeat = YES;
    [movie startProcessing];
    
    NSURL *videoUrl2 = [[NSBundle mainBundle] URLForResource:@"abc" withExtension:@"mp4"];
    GPUImageMovie*movie2 = [[GPUImageMovie alloc] initWithURL:videoUrl2];
    movie2.playAtActualSpeed = YES;
    movie2.shouldRepeat = YES;
    [movie2 startProcessing];
    
    GPUimageTransparent*filter3 = [[GPUimageTransparent alloc] init];
    [movie addTarget:filter3];
    [movie2 addTarget:filter3];
    
    
    GPUImageView*filterView = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];
    [filterView setFillMode:kGPUImageFillModeStretch];
    [filterView setInputRotation:kGPUImageNoRotation atIndex:0];
    [filterView setInputRotation:kGPUImageNoRotation atIndex:1];
    
    [filter3 addTarget:filterView];
    
    [self.view addSubview: filterView];
}

@end
